﻿<?php
$edit_url	=	"?act=list_ads";
if ($del_id) {
	acp_check_permission('del_link');
	if ($_POST['submit']) {
		$mysql->query("DELETE FROM ".$tb_prefix."ads WHERE ads_id = '".$del_id."'");
		echo "Đã xóa xong <meta http-equiv='refresh' content='0;url=".$edit_url."'>";
		exit();
	}
	?><table align=center><form method="post">Bạn có muốn xóa không ??????<br><center><input value="Có" name=submit type=submit class=submit></center></form></table><?
}
if($mode == 'edit') {
acp_check_permission('edit_link');
	if(is_numeric($id)) {
		$sql	=	"SELECT * FROM ".$tb_prefix."ads WHERE ads_id = $id";
		$query	=	$mysql->query($sql);
		if($mysql->num_rows($query)) {
			$row =	$mysql->fetch_array($query);
			$ads_WEB	=	$row['ads_web'];
			$ads_URL	=	$row['ads_url'];
			$ads_LOGO	=	$row['ads_img'];
			$action		=	"?act=ads&mode=edit&id=$id";
			if(isset($_POST['submit'])) {
				$web	=	$_POST['web'];
				$url	=	$_POST['url'];
				$logo	=	$_POST['logo'];
				$mysql->query("UPDATE ".$tb_prefix."ads SET
					ads_web				=  	'".$web."',
					ads_url 			= 	'".$url."',
					ads_img			=	'".$logo."' WHERE ads_id = '".$id."'");
				echo "<script language='JavaScript'>{ window.parent.location='?act=ads&mode=edit&id=$id' }</script>";
			}
		}
	}
	if(!$mysql->num_rows($query)) {
		die("Ads này chưa có trong data");
	}
include("templates/ads.html");
}
if($mode == 'add') {
acp_check_permission('add_link');
	if(isset($_POST['submit'])) {
		$web	=	$_POST['web'];
		$url	=	$_POST['url'];
		$logo	=	$_POST['logo'];
		$action	=	"?act=ads&mode=add";
		$mysql->query("INSERT INTO ".$tb_prefix."ads (ads_web,ads_url,ads_img) 
					VALUES ('".$web."','".$url."','".$logo."')");
		echo "<script language='JavaScript'>{ window.parent.location='?act=list_ads' }</script>";
	}
include("templates/ads.html");
}
?>